<?php
session_start();
/*
class Una extends Controller {
	var $name;

	function __construct($params) {
		parent::__construct();
		$fh = fopen("/home/marcelo/debug.txt", "a");
		fwrite($fh, get_class($this).".__construct(). hash:".spl_object_hash($this)."\n");
		fclose($fh);
	}

	function __destruct() {
		parent::__destruct();

		$fh = fopen("/home/marcelo/debug.txt", "a");
		fwrite($fh, get_class($this).".__destruct() name: ".$this->name." id:".$this->getId()." hash:".spl_object_hash($this)."\n");
		fclose($fh);
	}

	function setName($name) {
		$this->name = $name;
	}
}

class Otra extends Controller {
	var $unaId;
	var $name;

	function __construct($params) {
		parent::__construct();

		$fh = fopen("/home/marcelo/debug.txt", "a");
		fwrite($fh, get_class($this).".__construct() hash:".spl_object_hash($this)."\n");
		fclose($fh);

		$una = new Una($params);
		$this->unaId = $una->getId();
		unset($una);
	}

	function __destruct() {
		parent::__destruct();
		if ($this->deleted()) {
			//$una = Controller::getController("Una", $this->unaId);
			//$una->sessionDelete();
		}

		$fh = fopen("/home/marcelo/debug.txt", "a");
		fwrite($fh, get_class($this).".__destruct() name:".$this->name." id:".$this->getId()." hash:".spl_object_hash($this)."\n");
		fclose($fh);

		//$una = Controller::getController("Una", $this->unaId);
		//$fh = fopen("/home/marcelo/debug.txt", "a");
		//ob_start();
		//var_dump($_SESSION["controllers"]);
		//$data = ob_get_clean();
		//fwrite($fh, '$_SESSION["controllers"]: '.$data."\n");
		//fclose($fh);
	}

	// http://localhost/index.php?controller=Otra&do=getAlgo
	public function getAlgo($params) {
		$una = Controller::getController("Una", $this->unaId);
		$fh = fopen("/home/marcelo/debug.txt", "a");
		fwrite($fh, "getUna() ".$this->unaId." == ".$una->getId()." una.hash: ".spl_object_hash($una)."\n");
		fclose($fh);

		$una->setName("!!! Una.name desde otra. !!!\n");
		$this->name = "!!! Otra.name !!!";
		$this->redirectAgentTo("algo");
		$fh = fopen("/home/marcelo/debug.txt", "a");
		fwrite($fh, "Redirect -------------> algo() seted name: ".$this->name."\n");
		fclose($fh);
	}

	public function algo($params) {
		$fh = fopen("/home/marcelo/debug.txt", "a");
		fwrite($fh, "algo() Algo desde Otra (name: ".$this->name.")\n");

		$una = Controller::getController("Una", $this->unaId);
		fwrite($fh, "algo() Name de otra.una: ".$una->name."\n");
		fclose($fh);
	}
}

class Padre extends Controller {
	var $otraId;

	function __construct($params) {
		parent::__construct();

		$fh = fopen("/home/marcelo/debug.txt", "a");
		fwrite($fh, get_class($this).".__construct() name: hash:".spl_object_hash($this)."\n");
		fclose($fh);

		$otra = new Otra($params);
		$this->otraId = $otra->getId();
		unset($otra);
	}

	function __destruct() {
		parent::__destruct();
		$fh = fopen("/home/marcelo/debug.txt", "a");
		fwrite($fh, get_class($this).".__destruct() name: hash:".spl_object_hash($this)."\n");
		fclose($fh);
	}

	function dale($params) {
		$otra = Controller::getController("Otra", $this->otraId);
		
		$fh = fopen("/home/marcelo/debug.txt", "a");
		fwrite($fh, get_class($this).".getAlgo()\n");
		fclose($fh);

		$otra->getAlgo($params);
	}
}
*/
/*
function isValidId($id) {
	$valid = strlen($id) == (32 + 2);
	$valid = $valid && preg_match('/[abcdefABCDEF|0123456789]+/i', $id, $matches, PREG_OFFSET_CAPTURE, 2);
	$valid = $valid && "ID".$matches[0][0] == $id;
	return $valid;
}

$id = "ID185f65c9c8570e22c83e97405174f23e";

echo isValidId($id);
*/
/*
if (empty($_FILES['uploaded_file'])) {
?>
	<html>
		<head>
		</head>
		<body>
			<form action="http://visual-engine.blogsite.org/debug.php" method="post" enctype="multipart/form-data">
				<input name="uploaded_file" type="file" />
				<input value="subir" type="submit" />
			</form>
		</body>
	</html>
<?php
} else {
	if (!move_uploaded_file($_FILES['uploaded_file']['tmp_name'], "/mnt/hda2/development/visual-engine/web/files/".$_FILES['uploaded_file']['name'])) {
		echo 'error';
	} else {
		echo 'ok '.$_FILES['uploaded_file']['size'].' bytes';
	}
}
*/
/*
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
	</head>
	<body>
	</body>
	<script>
		var elarray = [];
		elarray[0] = 23;
		elarray[1] = 54;
		elarray[2] = 12;

		elarray.splice(1, 1);
		for (var i=0 ; i<elarray.length ; i++) {
			document.write(elarray[i] + "<br/>");
		}
	</script>
</html>

<?php
*/

eval("echo '';?> <html></html><?php echo '';");
?>
